﻿///<copyright>
/// Copyright © 2009 Stephen Styrchak. All Rights Reserved.
///</copyright>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using Ferpect.ComponentModel.Design;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace Ferpect.ComponentModel.Sprites
{
    [ProvideProperty("Movement", typeof(Sprite))]
    public class SpriteMovement : SpriteAnimation
    {
        private Dictionary<Sprite, MovementInfo> moveInfos;

        public SpriteMovement()
        {
            this.moveInfos = new Dictionary<Sprite, MovementInfo>();
        }

        [Category("Animation - Movement")]
        [DefaultValue(null)]
        [TypeConverter(TypeConverters.MovementInfoConverter)]
        public MovementInfo GetMovement(Sprite sprite)
        {
            MovementInfo info;
            if (!this.moveInfos.TryGetValue(sprite, out info))
            {
                info = new MovementInfo();
                this.moveInfos[sprite] = info;
            }
            return info;
        }

        public void SetMovement(Sprite sprite, MovementInfo info)
        {
            this.moveInfos[sprite] = info;
        }

        #region IUpdatableChildComponent

        public override void Update(GameTime gameTime)
        {
        }

        #endregion
    }
}
